package com.loadburn.heron.complier;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.loadburn.heron.render.adapter.JspRendering;
import com.loadburn.heron.render.Rendering;
import com.loadburn.heron.template.TemplateLoader;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author slacrey (scstlinfeng@yahoo.com)
 *         Date: 13-10-28
 */
@Singleton
public class HeronTemplateCompilerJsp implements HeronTemplateCompiler {


    private final Provider<HttpServletRequest> requestProvider;

    private final Provider<HttpServletResponse> responseProvider;

    @Inject
    public HeronTemplateCompilerJsp(Provider<HttpServletRequest> requestProvider,
                                    Provider<HttpServletResponse> responseProvider) {
        this.requestProvider = requestProvider;
        this.responseProvider = responseProvider;
    }

    @Override
    public Rendering compile(final TemplateLoader.TemplatePage templatePage) {
        return new JspRendering(requestProvider, responseProvider, templatePage);
    }

}
